package 力扣日常刷题.木22二月.第15天221;

/**
 * @author 帅小伙
 * @date 2022/2/21
 * @description
 */
public class Demo117两数之和II输入有序数组 {

    public int[] twoSum(int[] numbers, int target) {
        int n = numbers.length, l = 0, r = n - 1;

        while(l < r) {
            int t = numbers[r] + numbers[l];
            if(t == target) return new int[]{l+1,r+1};
            else if(t > target) r -- ;
            else l++;
        }
        return new int[]{-1,-1};
    }

}
